using System;
using System.Globalization;
using Avalonia.Data.Converters;

namespace AvalonAdmin.Converters
{
    /// <summary>
    /// 布尔值到文本转换器
    /// true -> "启用"
    /// false -> "禁用"
    /// </summary>
    public class BooleanToTextConverter : IValueConverter
    {
        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is bool boolValue)
            {
                return boolValue ? "启用" : "禁用";
            }
            
            return "未知";
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is string stringValue)
            {
                return stringValue == "启用";
            }
            
            throw new NotImplementedException();
        }
    }
}